<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
<script src="/js/jquery-3.4.1.min.js"></script>
<%
    String info = request.getParameter("info");
    if (info == null) {
        info = "";
    }%>
用户名:<input type="text" name="username" id="username"><br>
密码:<input type="password" name="password" id="password"><br>
<button id="login">登录</button>
<br>
<span id="info" style="color: red;"><span>

<script>
var info = '<%=info%>';
$(function () {
    $("#username").val("");
    $("#password").val("");
    if (info == "noauth") {
        $("#info").html("无权限直接访问，请先登录！");
        alert("无权限直接访问，请先登录！");
    }

    var user = {
        username: $("#username").val(),
        password: $("#password").val()
    };

    // 发送ajax请求
    $("#login").bind("click", function () {
        $.ajax({
            url: '/login/check',
            type: 'POST',
            data: {
                "username": $("#username").val(),
                "password": $("#password").val()
            },
            //contentType:'application/json;charset=utf-8',
            dataType: 'json',
            success: function (data) {
                if (data == true) {
                    window.location.href = '/resume/showResume'
                } else {
                    $("#info").html("用户名密码错误");
                    alert("用户名密码错误！");
                }
            }
        });
    });
});

</script>
</body>
</html>
